package com.cxf.windex.biz;

import com.cxf.windex.base.biz.BaseBiz;
import com.cxf.windex.entity.JsContents;
import com.cxf.windex.entity.VoiceTemplates;
import com.cxf.windex.mapper.VoiceTemplatesMapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 语音模板Biz
 * @author chenxf
 * @version V1.0
 * @date 2018-12-03 10:21
 **/
@Service
public class VoiceTemplatesBiz extends BaseBiz<VoiceTemplatesMapper, VoiceTemplates> {
    /**
     * 语音模板列表
     *
     * @param limit 数量
     * @param offset 页码
     * @param orderStr  排序(升序或者降序)
     * @param name 名称
     * @param tags 标签
     * @return
     */
    public List<VoiceTemplates> list(int limit, int offset, String orderStr, String name,String tags) {
        Example example = new Example(VoiceTemplates.class);
        Example.Criteria criteria = example.createCriteria();
        if(StringUtils.isNotBlank(name)){
            criteria.andLike("name",  "%"+name+"%" );
        }
        if(StringUtils.isNotBlank(tags)){
            criteria.andLike("tags",  "%"+tags+"%" );
        }
        example.setOrderByClause("crt_time " + orderStr);
        PageHelper.startPage(offset, limit);
        return selectByExample(example);
    }
}
